package com.ruoyi.framework.config;

import com.ruoyi.common.config.Global;
import com.ruoyi.framework.filter.ApiInterceptorAdapter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*
 * @Author chencundeng
 * @Description api配置信息类
 * @Date 2019/2/21
 **/
@Configuration
public class AppConfigurer implements WebMvcConfigurer {

    /**
     * 注入自定义拦截类到spring容器
     * @return
     */
    @Bean
    public ApiInterceptorAdapter getMyInterceptor(){
        return  new ApiInterceptorAdapter();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getMyInterceptor()) //指定拦截器类
                .addPathPatterns("/app/**"); //指定该类拦截的url
    }

}
